﻿
using RpcHelper;
using RpcModel;
using Wedonek.RpcStore.Service.DAL;
using Wedonek.RpcStore.Service.Interface;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Service.Collect
{
        internal class RpcControlCollect : BasicCollect<RpcControlDAL>, IRpcControlCollect
        {
                public void CheckIsRepeat(string ip,int port)
                {
                        if(base.BasicDAL.CheckIsRepeat (ip, port))
                        {
                                throw new ErrorException ("rpc.control.repeat");
                        }
                }
                public int Add (RpcControl add)
                {
                        return base.BasicDAL.Add (add);
                }
                public RpcControlInfo Get (int id)
                {
                        RpcControlInfo control= base.BasicDAL.Get (id);
                        if (control == null)
                        {
                                throw new ErrorException ("rpc.control.not.find");
                        }
                        return control;
                }

                public RpcControlInfo[] Query (IBasicPage paging, out long count)
                {
                        return base.BasicDAL.Query (paging, out count);
                }
                public void Set (RpcControlInfo control, RpcControl set)
                {
                        if (set.IsEquals (control))
                        {
                                return;
                        }
                        base.BasicDAL.Set (control.Id, set);
                }
                public void Delete (RpcControlInfo control)
                {
                        base.BasicDAL.Delete (control.Id);
                }
        }
}
